fix(telemetry): honor --config flag in enable/disable save path#375
Merged
Conversation
Deploying mcpproxy-docs with
|
| Latest commit: |
6eba334
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f72dc827.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-telemetry-config-flag-sa.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 24275590729 --repo smart-mcp-proxy/mcpproxy-go
|
The telemetry enable/disable commands correctly loaded config via loadTelemetryConfig() (which honors the --config flag) but then hardcoded the save path to config.GetConfigPath(cfg.DataDir), so `mcpproxy --config /custom.json telemetry disable` always wrote to ~/.mcpproxy/mcp_config.json instead of the custom path. This is a pre-existing bug introduced in PR #345 (Spec 036), not Spec 042. Add a small telemetryConfigSavePath helper that mirrors the load logic: prefer the package-level configFile flag when set, else fall back to GetConfigPath(DataDir). Apply it to runTelemetryEnable, runTelemetryDisable, and runTelemetryShowPayload (the latter passes the path to telemetry.New which persists the anonymous ID). Adds regression tests covering both enable and disable, plus a direct helper unit test, with HOME sandboxed to t.TempDir() so accidental writes to the real home config are detected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1157868 to
6eba334
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mcpproxy telemetry enable/telemetry disableignored the--configflag and always wrote to~/.mcpproxy/mcp_config.json.loadTelemetryConfig()correctly honors the package-levelconfigFileflag, but the save path was hardcoded toconfig.GetConfigPath(cfg.DataDir).telemetryConfigSavePath(cfg)helper that prefersconfigFilewhen set, else falls back to the default. Applied torunTelemetryEnable,runTelemetryDisable, andrunTelemetryShowPayload(the last one also passes the path totelemetry.New, which persists during legacy-install anonymous-ID initialization).This is a pre-existing bug from PR #345 (Spec 036), not Spec 042.
Reproduction (before the fix)
Test plan
go test ./cmd/mcpproxy/... -race -run Telemetry— passesgo test ./cmd/mcpproxy/... -race— passesgo build ./cmd/mcpproxy— succeeds./scripts/run-linter.sh— 0 issuesHOMEsandboxed tot.TempDir():TestRunTelemetryDisable_HonorsConfigFlag— disable writes to custom path, default path untouchedTestRunTelemetryEnable_HonorsConfigFlag— enable writes to custom pathTestTelemetryConfigSavePath_PrefersConfigFileFlag— helper unit testScope notes
cmd/mcpproxy/telemetry_cmd.goplus a new in-package test file.runTelemetryShowPayloadwas trivially updated to use the helper; a sister PR retargeting show-payload to daemon-mode can extend or refactor this call site without conflict.runTelemetryStatusis read-only and untouched.Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code